package com.guaoran.jvm;

import java.util.ArrayList;
import java.util.List;

/**
 * @author : guaoran
 * @Description
 *  javap -v 查看 class 的信息
 *  堆内存溢出
 * @date :2019/3/1 11:03
 */
public class JVMDemo {
    private String a;
    private final Object object = new Object();
    private static int b;

    //逃逸分析
    public static  JVMDemo create(){
        return new JVMDemo();
    }

    byte[] byteArray = new byte[1 * 1024 * 1024];
    //-Xms10m -Xmx80m -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDetails
    //设置堆初始化内存，最大堆内存，oom时 dump 出日志文件，打印GC信息
    public static void main(String[] args) {
        JVMDemo demo = JVMDemo.create();
        List<JVMDemo> list = new ArrayList<>();
        int count = 0;
        try {
            while (true){
                list.add(new JVMDemo());
                count ++;
            }
        }catch (Throwable e){
            System.out.println("count:"+ count);
            e.printStackTrace();
        }

    }
}
